#include "stdio.h"
#include "unistd.h"
#include "sys/types.h"
#include "sys/stat.h"
#include "sys/ioctl.h"
#include "fcntl.h"
#include "stdlib.h"
#include "string.h"
#include <poll.h>
#include <sys/select.h>
#include <sys/time.h>
#include <sys/ioctl.h>
#include <signal.h>
#include <fcntl.h>
#include <mpu6050.h>
int main()
{
    int fd;
    int ret;
    float ACC_X,ACC_Y,ACC_Z;
    
    struct MPU6050_DATA_t data;

    fd = open("/dev/MyMPU6050",O_RDWR);
    if(fd < 0) {
		printf("can't open file \"/dev/MyMPU6050\r\n\"");
		return -1;
	}
    while(1)
    {
        ret = ioctl(fd,MPU6050_GET,&data);
        ACC_X = data.Accel_Value[0]/2048.0;
        ACC_Y = data.Accel_Value[1]/2048.0;
        ACC_Z = data.Accel_Value[2]/2048.0;
        if(ret<0)
        {
            printf("ret:%d\n",ret);
            break;
        }
        // printf("Accel_X:%d,Accel_Y:%d,Accel_Z:%d,Gyro_X:%d,Gyro_Y:%d,Gyro_Z:%d\r\n",data.Accel_Value[0],data.Accel_Value[1],data.Accel_Value[2],data.Gyro_Value[0],data.Gyro_Value[1],data.Gyro_Value[2]);
        printf("Accel_X:%.6f,Accel_Y:%.6f,Accel_Z:%.6f\n",ACC_X,ACC_Y,ACC_Z);
    }
    return 0;
}